<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>


<table class="" style="width:96%;padding: 0;margin:2%">
	<tr>
		<td style="padding:8px">
			<div class="row">
				<p class="_100 small">
					<label for="">转派至处理人</label> <input id="username" name="username"
						style="display: none">
					<isperp:departmentUser displayValue="" valueControlId="username"
						displayValueCssClass="required" name="transferUsername"
						id="transferUsername"></isperp:departmentUser>
				</p>
			</div></td>
	</tr>
	<tr>
		<td style="padding:8px">
			<div class="row no-bg">
				<p class="_100">
					<label for="">转派原因</label>
					<textarea id="suggestion" name="suggestion" rows="6"
						class="required" style="width:97%"></textarea>
				</p>
			</div></td>
	</tr>
	<tr>
		<td style="padding:8px"><div class="row">
				<p class="_100 small">
					<label for="" style="font-weight: bold;">常用意见</label>
					<isperp:dictSelector id="transferAssigneeCommend"
						typeCode="BPM_COMMONS" onchangeFunc="appendToSuggestion(this)">
					</isperp:dictSelector>


				</p>
			</div>
		</td>
	</tr>

</table>
<isperp:buttonList buttonListId="approvelBtns">
	<button class="submit" onclick="submitProcess()">
		<span class="icon icon-ok"></span>提交
	</button>
</isperp:buttonList>
<script type="text/javascript">
	function submitProcess() {
		var username = $("#username").val();
		if (!username || username == "") {
			isperp.alert("请选择处理人！");
			return;
		}

		var sugVal = $("#suggestion").val();
		if (!sugVal || sugVal == "") {
			isperp.alert("请填写转派原因！");
			return;
		}

		$("#approvelBtns").hide();
		$("#approvelBtns").parent().append("<label style='float:right;font-size:14px;color:red;'>正在提交，请稍后......</lable>");
		$.post("workflow/processRun/transferAssignee", {
			"processId" : "${processId}",
			"username" : username,
			"suggestion" : sugVal
		}, function(result) {
			if (result.success) {
				isperp.alert("任务已提交至：" + $("#transferUsername").val());
				isperp.reloadParentControl();
				isperp.closeDialog({
					closeParent : true,
					callback : function() {
					}
				});
			}

		});

	}

	function appendToSuggestion(obj) {
		var sug = $("#suggestion");
		sug.val(sug.val() + $(obj).val());
	}
</script>

